{% include "../public/min-header.html" %}
<style>
	.iconspan{padding:1px;}
</style>
<div class="wrapper">
 	<form method="post" id="handlepost" action="{{helper.pathFor('adstctm')}}">
      	<input type="hidden" name="mod_id" value="{{menu.mod_id}}">
      	<div class="tab-content col-md-10">                 	  
          	<div class="tab-pane active" id="tab_tongyong">                           
		        <table class="table table-bordered">
		            <tbody>
			            <tr>
			                <td class="col-sm-2">菜单名称：</td>
			                <td class="col-sm-8">
			                    <input type="text" class="form-control" name="title" value="{% if act == 'edit'%}{{menu.title}} {% endif %}" >
			                </td>
			            </tr> 
			            <tr>
				            <td>上级菜单：</td>
				            <td>
						   		{% if menu.module == 'top' and act == 'edit' %}
									顶级菜单
								{% else %}
									<select name="parent_id" id="parent_id" value="{{menu.parent_id}}">
										{% if not menu and  not pid %}
										<option value="0">顶级菜单</option>
										{% endif %}
										{% for v in tree %}
                                            {% if v %}
											<option value="{{v.mod_id}}" {% if v.mod_id == menu.parent_id or v.mod_id == pid  %} selected="selected"{% endif %}>&nbsp;&nbsp;|--{{v.title}}</option>
                                            {% endif%}
										{% endfor%}
									</select>
								{% endif %}
				            </td>
			            </tr>
			            <tr>
			            	<td>图标：</td>
			            	<td>
			            		<div class="row">
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-tasks' %}checked{% endif %} name="icon" value="fa-tasks">&nbsp;&nbsp;<i class="fa fa-tasks"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-cog' %}checked{% endif %} name="icon" value="fa-cog">&nbsp;&nbsp;<i class="fa fa-cog"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-dashboard' %}checked{% endif %} name="icon" value="fa-dashboard">&nbsp;&nbsp;<i class="fa fa-dashboard"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-retweet' %}checked{% endif %} name="icon" value="fa-retweet">&nbsp;&nbsp;<i class="fa fa-retweet"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-navicon' %}checked{% endif %} name="icon" value="fa-navicon">&nbsp;&nbsp;<i class="fa fa-navicon"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-table' %}checked{% endif %} name="icon" value="fa-table">&nbsp;&nbsp;<i class="fa fa-table"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-chart' %}checked{% endif %} name="icon" value="fa-bar-chart">&nbsp;&nbsp;<i class="fa fa-bar-chart"></i></span>
			            		</div>
			            		<div class="row">
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-plug' %}checked{% endif %} name="icon" value="fa-plug">&nbsp;&nbsp;<i class="fa fa-plug"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-book' %}checked{% endif %} name="icon" value="fa-book">&nbsp;&nbsp;<i class="fa fa-book"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-flag' %}checked{% endif %} name="icon" value="fa-flag">&nbsp;&nbsp;<i class="fa fa-flag"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-home' %}checked{% endif %} name="icon" value="fa-home">&nbsp;&nbsp;<i class="fa fa-home"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-pencil' %}checked{% endif %} name="icon" value="fa-pencil">&nbsp;&nbsp;<i class="fa fa-pencil"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-star' %}checked{% endif %} name="icon" value="fa-star">&nbsp;&nbsp;<i class="fa fa-star"></i></span>
			            			<span class="iconspan"><input type="radio" {% if menu.icon == 'fa-user' %}checked{% endif %} name="icon" value="fa-user">&nbsp;&nbsp;<i class="fa fa-user"></i></span>
			            		</div>
			            	</td>
			            </tr>
			            <tr>
			                <td>排序：</td>
			                <td><input type="text" name="orderby" value="{% if menu.orderby > 0 %}{{menu.orderby}}{% else %}50{% endif%}" /></td>
			            </tr>
		            </tbody> 
		            <tfoot>
		            	<tr>
			            	<td>
			            		<input type="hidden" name="act" value="{{act}}">
			            	</td>
			            	<td class="text-right">
			            		<input class="btn btn-primary" type="button" onclick="dataSave()" value="保存">
			            	</td>
		            	</tr>
		            </tfoot>                               
	          	</table>
      		</div>                           
  		</div>              
	</form>
</div>
<script type="text/javascript">
	function dataSave(){
		var title = $('input[name="title"]').val();
		var parent_id = $('#parent_id').val();
		var orderby = $('input[name="orderby"]').val();
		var act = $('input[name="act"]').val();
		var mod_id = $('input[name="mod_id"]').val();
		var icon = $('input:radio[name="icon"]:checked').val();
        var _csrf = $('input[name="_csrf"]').val();
		$.ajax({
			url : "{{helper.pathFor('adstctm')}}",
			data : {title:title,parent_id:parent_id,orderby:orderby,act:act,mod_id:mod_id,icon:icon,_csrf:_csrf},
			type : 'post',
			dataType : 'json',
			success :function(data){
				if(data.status==1){
					window.parent.call_back(1);	
				}else{
					window.parent.call_back(0);
				}						
			}			
		});		
	}
</script>
{% include "../public/main-footer.html" %}
